//
//  ThreadState_VC.m
//  DXC
//
//  Created by TOPTEAM on 2017/5/8.
//  Copyright © 2017年 TOPTEAM. All rights reserved.
//

#import "ThreadState_VC.h"

@interface ThreadState_VC ()

@end

@implementation ThreadState_VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor=[UIColor whiteColor];
    self.title=@"线程状态";
    
    
    // Do any additional setup after loading the view.
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    //创建线程
    NSThread *thread = [[NSThread alloc]initWithTarget:self selector:@selector(run2) object:nil];
    //启动线程
    [thread start];
}

-(void)run2
{
    for (NSInteger i=0; i<100; i++) {
        NSLog(@"%@--%zd",[NSThread currentThread],i);
        if (50 == i) {
            //死亡
            //            [NSThread exit];
            //            return;
            
            break;
        }
    }
}
-(void)run
{
    NSLog(@"-----");
    //阻塞线程
    //    [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];
    
    [NSThread sleepForTimeInterval:3.0];
    //    NSLog(@"%@",[NSDate distantFuture]);
    
    //    [NSThread sleepForTimeInterval:3.0];
    //    [NSThread sleepUntilDate:[NSDate distantFuture]];
    //    [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:3.0]];
    NSLog(@"+++++++");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}




@end
